﻿using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;

namespace WordpressRestApi
{
    /// <summary>Blog post.</summary>
    /// <remarks>Defined in https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/posts/%24post_ID </remarks>
    public class PostInfo
    {
        /// <summary>Post ID.</summary>
        public int ID { get; set; }

        /// <summary>Author of the post.</summary>
        [JsonProperty("author")]
        public object Author { get; set; }

        /// <summary>Datetime the post was created.</summary>
        [JsonProperty("date")]
        public DateTime Date { get; set; }

        /// <summary>Datetime the post was last modified.</summary>
        [JsonProperty("modified")]
        public DateTime ModifiedDate { get; set; }

        /// <summary>Title.</summary>
        [JsonProperty("title")]
        public string Title { get; set; }

        /// <summary>Url of the post.</summary>
        [JsonProperty("URL")]
        public string Url { get; set; }

        /// <summary>The wp.me short URL.</summary>
        [JsonProperty("short_URL")]
        public string ShortUrl { get; set; }

        /// <summary>Content of the post.</summary>
        [JsonProperty("content")]
        public string Content { get; set; }

        /// <summary>Content-excerpt of the post.</summary>
        [JsonProperty("excerpt")]
        public string Excerpt { get; set; }

        /// <summary>The name (slug) for the post, used in URLs.</summary>
        [JsonProperty("slug")]
        public string Slug { get; set; }

        /// <summary>Post's Guid.</summary>
        [JsonProperty("guid")]
        public string Guid { get; set; }

        /// <summary>Post's status.</summary>
        [JsonProperty("status")]
        [JsonConverter(typeof(StringEnumConverter))]
        public PostStatus Status { get; set; }

        /// <summary>Is the post sticky?</summary>
        [JsonProperty("sticky")]
        public bool IsSticky { get; set; }

        /// <summary>Plain text password of the post (or empty).</summary>
        [JsonProperty("password")]
        public string Password { get; set; }

        /// <summary>Parent post if any.</summary>
        [JsonProperty("parent")]
        public object Parent { get; set; }

        /// <summary>Post type.</summary>
        [JsonProperty("type")]
        public string Type { get; set; }

        /// <summary>Discussion hash.</summary>
        [JsonProperty("discussion")]
        public object Discussion { get; set; }

        /// <summary>Is the post open to likes?</summary>
        [JsonProperty("likes_enabled")]
        public bool IsLikesEnabled { get; set; }

        /// <summary> Should sharing buttons show on this post?</summary>
        [JsonProperty("sharing_enabled")]
        public bool IsSharingEnabled { get; set; }

        /// <summary>The number of likes for this post.</summary>
        [JsonProperty("like_count")]
        public int LikeCount { get; set; }

        /// <summary>Does the current user like this post?</summary>
        [JsonProperty("i_like")]
        public bool IsILike { get; set; }

        /// <summary>Did the current user reblog this post?</summary>
        [JsonProperty("is_reblogged")]
        public bool IsReblogged { get; set; }

        /// <summary>Is the current user following this blog?</summary>
        [JsonProperty("is_following")]
        public bool IsFollowing { get; set; }

        /// <summary>A unique WordPress.com-wide representation of a post.</summary>
        [JsonProperty("global_ID")]
        public string GlobalID { get; set; }

        /// <summary>The URL to the featured image for this post if it has one.</summary>
        [JsonProperty("featured_image")]
        public string FeaturedImageUrl { get; set; }

        /// <summary>The attachment object for the featured image if it has one.</summary>
        [JsonProperty("post_thumbnail")]
        public object PostThumbnail { get; set; }

        /// <summary>Post's format.</summary>
        [JsonProperty("format")]
        [JsonConverter(typeof(StringEnumConverter))]
        public PostFormat Format { get; set; }

        /// <summary>Geography.</summary>
        [JsonProperty("geo")]
        public object Geo { get; set; }

        /// <summary>The order pages should appear in.</summary>
        /// <remarks>For pages only.</remarks>
        [JsonProperty("menu_order")]
        public int MenuOrder { get; set; }

        /// <summary>The page template this page is using.</summary>
        /// <remarks>For pages only.</remarks>
        [JsonProperty("page_template")]
        public string PageTemplate { get; set; }

        /// <summary>Array of Twitter and Facebook URLs published by this post.</summary>
        [JsonProperty("publicize_URLs")]
        public string[] PublicizeUrls { get; set; }

        /// <summary>Hash of tags (keyed by tag name) applied to the post.</summary>
        [JsonProperty("tags")]
        public IDictionary<string, TagInfo> Tags { get; set; }

        /// <summary>Hash of categories (keyed by category name) applied to the post.</summary>
        [JsonProperty("categories")]
        public object Categories { get; set; }

        /// <summary>
        /// Hash of post attachments (keyed by attachment ID). Returns the most recent 20 attachments.
        /// Use the `/sites/$site/media` endpoint to query the attachments beyond the default of 20 that are
        /// returned here.
        /// </summary>
        [JsonProperty("attachments")]
        public object Attachments { get; set; }

        /// <summary>
        /// The total number of attachments for this post. Use the `/sites/$site/media` endpoint
        /// to query the attachments beyond the default of 20 that are returned here.
        /// </summary>
        [JsonProperty("attachment_count")]
        public int AttachmentCount { get; set; }

        /// <summary>List of post-specific permissions for the user; publish_post, edit_post, delete_post.</summary>
        [JsonProperty("capabilities")]
        public object Capabilities { get; set; }
    }
}